#ifndef __TASKQUEUE_H__

#define __TASKQUEUE_H__

#include <pthread.h>

#define PTHREAD_EXIT 1
#define PTHREAD_NOTEXIT 0
#define TASK_MAXNUM 1000

typedef struct tasknode{
    int peerfd;
    struct tasknode* next;
}task_t;

typedef struct taskqueue{
    task_t* front;
    task_t* rear;
    int size;
    int maxsize;
    pthread_cond_t notfull;
    pthread_cond_t notempty;
    int exitflag;
    pthread_mutex_t mutex;
}taskqueue_t;

void queue_init(taskqueue_t * q);
void queue_destroy(taskqueue_t *q);
void enqueue(taskqueue_t* q,int fd);
int dequeue(taskqueue_t* q);
int isempty(taskqueue_t* q);
int queuesize(taskqueue_t* q);
void wakeupqueue(taskqueue_t* q);

#endif
